<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="mini" label-width="68px">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-form-item label="项目区域" prop="projectRegion">
            <el-select v-model="queryParams.projectRegion" placeholder="请选择" clearable
              @keyup.enter.native="handleQuery">
              <el-option v-for="dict in dict.type.cld_project_region" :key="dict.value" :label="dict.label"
                :value="parseInt(dict.value)"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="项目名称">
            <el-input v-model="queryParams.projectName" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="资产名称">
            <el-input v-model="queryParams.assetsName" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="资产ID">
            <el-input v-model="queryParams.assetsIdCard" placeholder="请输入" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="资产状态">
            <el-select v-model="queryParams.recordStatus" placeholder="请选择" clearable @keyup.enter.native="handleQuery">
              <el-option v-for="dict in recordStatusOptions" :key="dict.value" :label="dict.label"
                :value="parseInt(dict.value)"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4" label-width="10px">
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>


    </el-form>
    <el-table v-loading="loading" :data="list" border>
      <el-table-column label="资产名称" align="center" prop="assetsName" />
      <el-table-column label="型号" align="center" prop="assetsModel" />
      <el-table-column label="资产ID" align="center" prop="assetsIdCard" />
      <el-table-column label="资产状态" align="center" prop="recordStatus">
        <template slot-scope="scope">
          <dict-tag :options="recordStatusOptions" :value="scope.row.recordStatus" />
        </template>
      </el-table-column>
      <el-table-column label="项目区域" align="center" prop="projectRegion">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.cld_project_region" :value="scope.row.projectRegion" />
        </template>
      </el-table-column>
      <el-table-column label="项目名称" align="center" prop="projectName" />
      <el-table-column label="项目业态" align="center" prop="projectBusiness">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.cld_project_business" :value="scope.row.projectBusiness" />
        </template>
      </el-table-column>
      <el-table-column label="单价" align="center" prop="bulMoney">
        <template slot-scope="scope">
          {{ toMoney(scope.row.bulMoney) }}
        </template>
      </el-table-column>
      <el-table-column label="折旧期限" align="center" prop="assetsPeriodNumber" />
      <el-table-column label="维修金额" align="center">
        <template slot-scope="scope">
          {{ toMoney(scope.row.repairOtherMoney + scope.row.repairMoney) }}
        </template>
      </el-table-column>
      <el-table-column label="折旧金额" align="center" prop="depreciationMoney">
        <template slot-scope="scope">
          {{ toMoney(scope.row.depreciationMoney) }}
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
import { selectCldAssetsDetailsList } from '@/api/cld/assets'
import { recordStatusOptions } from '@/assets/staticDict'
export default {
  name: "assetsDetails",
  dicts: ['cld_project_region', 'cld_project_business'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 列表数据
      list: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        assetsIdCard: null,
        projectRegion: null,
        projectName: null,
        assetsName: null,
        recordStatus: null
      },
      recordStatusOptions: recordStatusOptions
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      selectCldAssetsDetailsList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        assetsIdCard: null,
        projectRegion: null,
        projectName: null,
        assetsName: null,
        recordStatus: null
      }
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
<style scoped>
.el-select {
  width: 100%;
}
</style>
